/* 逾期信息  */
var firstHistoryList_zhujieren = true;
var firstHistoryList_peiou = true;
var firstHistoryList_danbaoren1 = true;
var firstHistoryList_danbaoren2 = true;
var firstHistoryList_danbaoren3 = true;
var firstHistoryList_danbaoren4 = true;
var getHistoryList = function(url, target, targetIdNo){
	target = target || 'zhujieren';
	var finalFirstHistoryList = true;
	if(target == 'zhujieren') {
		finalFirstHistoryList = firstHistoryList_zhujieren;
		firstHistoryList_zhujieren = false;
	} else if (target == 'peiou') {
		finalFirstHistoryList = firstHistoryList_peiou;
		firstHistoryList_peiou = false;
	} else if (target == 'danbaoren1') {
		finalFirstHistoryList = firstHistoryList_danbaoren1;
		firstHistoryList_danbaoren1 = false;
	} else if (target == 'danbaoren2') {
		finalFirstHistoryList = firstHistoryList_danbaoren2;
		firstHistoryList_danbaoren2 = false;
	} else if (target == 'danbaoren3') {
		finalFirstHistoryList = firstHistoryList_danbaoren3;
		firstHistoryList_danbaoren3 = false;
	} else if (target == 'danbaoren4') {
		finalFirstHistoryList = firstHistoryList_danbaoren4;
		firstHistoryList_danbaoren4 = false;
	}
	if(finalFirstHistoryList) {
		var winWidth = $(window).width();
	   	var winHeight = $(window).height() / 2.5;
	   	var win = winWidth /8 - 25;
	    $.jgrid.defaults.styleUI = 'Bootstrap';
		$("#table_list_" + target).jqGrid({
			postData:{busiId:busiId, targetIdNo:targetIdNo},
			url:url,
	       	datatype : "json",
		    colNames : ['历史订单时间','历史角色','主借人', '主借人身份证','订单状态', '签约贷款额', '车辆性质', '贷款银行'],
		    colModel : [ 
	             {name: 'submitTime',index: 'cusName',width: win,align: "center",sortable:false},
	             {name: 'creditPeopleType',index: 'dateOverdue',width: win,align: "center",sortable:false},
	             {name: 'cusName',index: 'cusIdno',width: win,align: "center",sortable:false},
	             {name: 'cusNo',index: 'amountMonthly',width: win,align: "center",sortable:false},
	             {name: 'busiStatus',index: 'loanAmount',width: win,align: "center",sortable:false},
	             {name: 'signLoanAmount',index: 'feeTotal',width: win,align: "center",sortable:false},
	             {name: 'carType',index: 'amountRemainder',width: win,align: "center",sortable:false},
	             {name: 'bankLoan',index: 'balanceCard',width: win,align: "center",sortable:false}
	          ],
	           mtype : "post",
	           height: winHeight,
	           autowidth: true,
	           shrinkToFit: true,
	           rowNum: 30,
	           rowList: [30, 60, 90, 120, 150],
	           viewrecords: true,
	           hidegrid: false,
	           multiselect : false,
	           multiboxonly:false,  
	           beforeSelectRow: false,
	           jsonReader: {
	                root: "result.rows",
	                page: "result.page",
	                total: "result.total",
	                records: "result.records",
	                repeatitems: false,
	                id: "replaceId"
	          },
	          loadComplete:function(datas){
	        	  	 if (datas.flag == "100100") {
	                     layer.msg("查询成功!", {icon: 6, time: 1000});
	                     var result = datas.result;
	                     
	                     var zhujieren_idno = result.zhujieren_idno;
	                     if(zhujieren_idno && zhujieren_idno != '') {
	                    	 showLi('zhujieren', 'History');
	                    	 $('#zhujierenLiHistory').attr('targetIdNo', zhujieren_idno);
	                     } else {
	                    	 hideLi('zhujieren', 'History');
	                    	 $('#zhujierenLiHistory').removeAttr('targetIdNo');
	                     }
	                     var peiou_idno = result.peiou_idno;
	                     if(peiou_idno && peiou_idno != '') {
	                    	 showLi('peiou', 'History');
	                    	 $('#peiouLiHistory').attr('targetIdNo', peiou_idno);
	                     } else {
	                    	 hideLi('peiou', 'History');
	                    	 $('#peiouLiHistory').removeAttr('targetIdNo');
	                     }
	                     var danbaoren1_idno = result.danbaoren1_idno;
	                     if(danbaoren1_idno && danbaoren1_idno != '') {
	                    	 showLi('danbaoren1', 'History');
	                    	 $('#danbaoren1LiHistory').attr('targetIdNo', danbaoren1_idno);
	                     } else {
	                    	 hideLi('danbaoren1', 'History');
	                    	 $('#danbaoren1LiHistory').removeAttr('targetIdNo');
	                     }
	                     var danbaoren2_idno = result.danbaoren2_idno;
	                     if(danbaoren2_idno && danbaoren2_idno != '') {
	                    	 showLi('danbaoren2', 'History');
	                    	 $('#danbaoren2LiHistory').attr('targetIdNo', danbaoren2_idno);
	                     } else {
	                    	 hideLi('danbaoren2', 'History');
	                    	 $('#danbaoren2LiHistory').removeAttr('targetIdNo');
	                     }
	                     var danbaoren3_idno = result.danbaoren3_idno;
	                     if(danbaoren3_idno && danbaoren3_idno != '') {
	                    	 showLi('danbaoren3', 'History');
	                    	 $('#danbaoren3LiHistory').attr('targetIdNo', danbaoren3_idno);
	                     } else {
	                    	 hideLi('danbaoren3', 'History');
	                    	 $('#danbaoren3LiHistory').removeAttr('targetIdNo');
	                     }
	                     var danbaoren4_idno = result.danbaoren4_idno;
	                     if(danbaoren4_idno && danbaoren4_idno != '') {
	                    	 showLi('danbaoren4', 'History');
	                    	 $('#danbaoren4LiHistory').attr('targetIdNo', danbaoren4_idno);
	                     } else {
	                    	 hideLi('danbaoren4', 'History');
	                    	 $('#danbaoren4LiHistory').removeAttr('targetIdNo');
	                     }
	                     
	                     var targetCusName = result.targetCusName;
	                     var targetIdno = result.targetIdno;
	                     if(targetCusName && targetCusName != '') {
	                    	 $('#history_' + target + '_name').html(targetCusName);
	                     }
	                     
	                     if(targetIdno && targetIdno != '') {
	                    	 $('#history_' + target + '_idno').html(targetIdno);
	                     }
	                     
	                     return;
	                 }
	            	if(datas.flag == '100802') {
	  				  top.location.href = thisLoginUrl;
	  				  return;
	  			  	}
	          	  	layer.msg(datas.message, {icon: 2});
	          }
	  });
	} else {
		 var postData = $("#table_list_" + target).jqGrid("getGridParam", "postData");
 		 $.extend(postData, {busiId:busiId, targetIdNo:targetIdNo});
         $("#table_list_" + target).jqGrid("setGridParam", { search: true }).trigger("reloadGrid", [{ page: 1}]);
	}
}
